package com.ruibang.glass.produce.controller.hotRealTime;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruibang.glass.produce.domain.req.ThicknessTrendRuleReq;
import com.ruibang.glass.produce.entity.ThicknessTrendRule;
import com.ruibang.glass.produce.service.ThicknessTrendRuleService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-02-05  15:16
 * @Description: TODO
 * @Version: 1.0
 */
@Api(tags = "测厚数据规则控制器")
@RestController
@RequestMapping("/api/glass/produce/hotRealTime/thicknessTrendRule")
public class ThicknessTrendRuleController {

    @Autowired
    private ThicknessTrendRuleService thicknessTrendRuleService;

    @PostMapping("/query")
    @ApiOperation(value = "查询规则", response = ResultBody.class)
    public ResultBody<Page<ThicknessTrendRule>> query(@RequestBody ThicknessTrendRuleReq thicknessTrendRuleReq) {
        return ResultBody.success(thicknessTrendRuleService.query(thicknessTrendRuleReq));
    }

    @PostMapping("/insert")
    @ApiOperation(value = "保存", response = ResultBody.class)
    public ResultBody insert(@RequestBody @Valid ThicknessTrendRule thicknessTrendRule) {
        thicknessTrendRuleService.insert(thicknessTrendRule);
        return ResultBody.success();
    }

    @PutMapping("/edit")
    @ApiOperation(value = "修改", response = ResultBody.class)
    public ResultBody edit(@RequestBody @Valid ThicknessTrendRule thicknessTrendRule) {
        thicknessTrendRuleService.edit(thicknessTrendRule);
        return ResultBody.success();
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "根据ID删除", response = ResultBody.class)
    public ResultBody deleteById(@PathVariable String id) {
        thicknessTrendRuleService.deleteById(id);
        return ResultBody.success();
    }
}
